package com.project.isaacwiki.controller;

import com.project.isaacwiki.service.ServiceUserOpera;
import com.project.isaacwiki.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@CrossOrigin
public class ControllerUserOpera {

    @Autowired
    private ServiceUserOpera serviceUserOpera;

    @GetMapping("/getUser")
    public Result getUser(Integer id)
    {
        return serviceUserOpera.getUser(id);
    }

    @PostMapping("/updateImage")
    public Result updateImage(MultipartFile file) throws Exception
    {
        return serviceUserOpera.updateImage(file);
    }

    @PostMapping("/updateUserInfo")
    public Result updateUserInfo(Integer id, String name, String imgUrl) throws Exception {
        return serviceUserOpera.updateUserInfo(id, name, imgUrl);
    }

    @PostMapping("/updateUserPasswordById")
    public Result updateUserPasswordById(Integer id, String oldPassword, String newPassword) throws Exception {
        return serviceUserOpera.updateUserPasswordById(id, oldPassword, newPassword);
    }
}
